package cn.wss.flowable.common;

import java.util.List;
import java.util.Map;

public class Page<T> {

  private int pageNum = 1;

  private int pageSize = 10;

  private List<T> data;

  private long totalElements;

  public Page() {
  }

  public Page(int pageNum, int pageSize) {
    this.pageNum = pageNum;
    this.pageSize = pageSize;
  }

  public Page(Map<String, Object> paramsMap) {
    if (paramsMap.containsKey("pageNum")) {
      Integer num = (Integer) paramsMap.get("pageNum");
      if (num != null && num > 0) {
        this.pageNum = num;
      }
    }
    if (paramsMap.containsKey("pageSize")) {
      Integer size = (Integer) paramsMap.get("pageSize");
      if (size != null && size > 0) {
        pageSize = size;
      }
    }
  }

  public int getPageSize() {
    return pageSize;
  }

  public void setPageSize(int pageSize) {
    this.pageSize = pageSize;
  }

  public int getPageNum() {
    return pageNum;
  }

  public void setPageNum(int pageNum) {
    this.pageNum = pageNum;
  }

  public List<T> getData() {
    return data;
  }

  public void setData(List<T> data) {
    this.data = data;
  }

  public long getTotalElements() {
    return totalElements;
  }

  public void setTotalElements(long totalElements) {
    this.totalElements = totalElements;
  }
}
